package com.xc.handler;

import com.xc.exception.BaseException;
import com.xc.vo.ResultVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理器
 */
@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(BaseException.class)
    public ResultVO<Object> BaseExceptionHandler(BaseException ex) {
        log.info("异常信息开始执行：👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇👇⬇");
        log.error("异常信息:", ex);
        log.info("异常信息结束执行。👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆👆⬆");
        return ResultVO.error(ex.getErrorCode(), ex.getMessage());
    }
}